{% extends "sentry/bases/admin.html" %}

{% load crispy_forms_tags %}
{% load i18n %}
{% load sentry_admin_helpers %}
{% load sentry_helpers %}

{% block title %}{% trans "Change User" %} | {{ block.super }}{% endblock %}

{% block main %}
    <section class="body">
        <h3>User Details <small>{{ the_user.username }}</small></h3>
        <form action="" method="post">
            {% csrf_token %}
            {{ form|as_crispy_errors }}
            {% for field in form %}
                {{ field|as_crispy_field }}
            {% endfor %}
            <fieldset class="form-actions">
                <button type="submit" class="btn btn-primary">{% trans "Save Changes" %}</button>
                {% if the_user.id != request.user.id %}
                    <a href="{% url 'sentry-admin-remove-user' the_user.pk %}" class="btn btn-danger">{% trans "Remove User" %}</a>
                {% else %}
                    <a href="#" class="btn disabled btn-danger">{% trans "Cannot remove yourself" %}</a>
                {% endif %}
            </fieldset>
        </form>
        <br />
        {% if project_list %}
            <h4>{% trans "Projects" %}</h4>
            <table class="table table-bordered table-striped">
                <colgroup>
                    <col>
                    <col style="width:150px;">
                    <col style="width:150px;">
                </colgroup>
                <thead>
                    <tr>
                        <th>{% trans "Project" %}</th>
                        <th style="text-align:center;">{% trans "Daily Events" %}</th>
                    </tr>
                </thead>
                <tbody>
                    {% for project, avg_events in project_list|with_event_counts %}
                        <tr>
                            <td>
                                {{ project.slug }} <a href="{% absolute_uri '/{}/{}/' project.organization.slug project.slug %}">[view]</a>
                                </a>
                            </td>
                            <td style="text-align:center; vertical-align:middle;">
                                <em>~{{ avg_events }}</em>
                            </td>
                        </tr>
                    {% endfor %}
                </tbody>
            </table>
        {% endif %}
    </section>
{% endblock %}
